From acd5a62ae9c9fb33baf0314b659c9dce74176f49 Mon Sep 17 00:00:00 2001 From: "vhanquez@kneesa.uk.xensource.com" Date: Thu, 11 May 2006 15:01:54 +0100 Subject: [PATCH] Try to create runtime xenstored's directories at startup time. Signed-off-by: Vincent Hanquez --- tools/xenstore/xenstored_core.c | 15 +++++++++++++++ tools/xenstore/xs_lib.c | 4 ++-- tools/xenstore/xs_lib.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index a79e2dcf0c..2dcf9cf591 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1811,6 +1811,21 @@ int main(int argc, char *argv[]) reopen_log(); + /* make sure xenstored directory exists */ + if (mkdir(xs_daemon_rundir(), 0755)) { + if (errno != EEXIST) { + perror("error: mkdir daemon rundir"); + exit(-1); + } + } + + if (mkdir(xs_daemon_rootdir(), 0755)) { + if (errno != EEXIST) { + perror("error: mkdir daemon rootdir"); + exit(-1); + } + } + if (dofork) { openlog("xenstored", 0, LOG_DAEMON); daemonize(); diff --git a/tools/xenstore/xs_lib.c b/tools/xenstore/xs_lib.c index 226a8487f7..750d1823cf 100644 --- a/tools/xenstore/xs_lib.c +++ b/tools/xenstore/xs_lib.c @@ -26,13 +26,13 @@ /* Common routines for the Xen store daemon and client library. */ -static const char *xs_daemon_rootdir(void) +const char *xs_daemon_rootdir(void) { char *s = getenv("XENSTORED_ROOTDIR"); return (s ? s : "/var/lib/xenstored"); } -static const char *xs_daemon_rundir(void) +const char *xs_daemon_rundir(void) { char *s = getenv("XENSTORED_RUNDIR"); return (s ? s : "/var/run/xenstored"); diff --git a/tools/xenstore/xs_lib.h b/tools/xenstore/xs_lib.h index c62c457e61..f55008281a 100644 --- a/tools/xenstore/xs_lib.h +++ b/tools/xenstore/xs_lib.h @@ -46,6 +46,8 @@ struct xs_permissions #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2) /* Path for various daemon things: env vars can override. */ +const char *xs_daemon_rootdir(void); +const char *xs_daemon_rundir(void); const char *xs_daemon_socket(void); const char *xs_daemon_socket_ro(void); const char *xs_domain_dev(void); -- 2.30.2